import httpUtil from "../utils/httpUtil"
import logApi from "./logApi"

/**
 * @see https://console-docs.apipost.cn/preview/d6950e962940a169/ea5c94695c40d0d5?target_id=87209fc6-5b30-4c2f-8445-6c2b75673b1a
 */
const submitOrder = (params, successHandler, errHandler) => {

	logApi.addXimaLayaLog('提交订单之前，请求参数' + JSON.stringify(params))
	httpUtil.post("/api/xmly/api_order", params, res => {
		logApi.addXimaLayaLog('提交订单之后，请求参数' + JSON.stringify(params) + '。返回：' + JSON.stringify(res))

		if (successHandler) {
			successHandler(res)
		}
	}, err => {
		if (errHandler) {
			errHandler(res)
		}
	})
}

export default {
	submitOrder,
}